home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / pascal / toolbox.exe / TOOLDEMO.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-02-25  |  3.2 KB  |  113 lines

  1. {************************************************}
  2. {                                                }
  3. {   ToolDemo.pas                                 }
  4. {                                                }
  5. {************************************************}
  6.  
  7. program ToolDemo;
  8.  
  9. {$R TOOLDEMO.RES}
  10.  
  11. uses WObjects, WinTypes, WinProcs, Strings, ToolBox;
  12.  
  13. const
  14.   cm_Test = 1010;
  15.  
  16. type
  17.  
  18.   { Define a TApplication descendant }
  19.   TToolDemoApp = object(TApplication)
  20.     procedure InitMainWindow; virtual;
  21.   end;
  22.  
  23.   PToolChild = ^TToolChild;
  24.   TToolChild = object(TToolBox)
  25.      constructor Init(AParent : PWindowsObject; ATitle : PChar);
  26.      procedure TBButtonHit(var Msg : TMessage); virtual wm_First + tb_buttonhit;
  27.   end;
  28.  
  29.   PToolParent = ^TToolParent;
  30.   TToolParent = object(TWindow)
  31.     ToolChild : PToolChild;
  32.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  33.     procedure SetupWindow; virtual;
  34.   end;
  35.  
  36.   PMainMDIWindow = ^TMainMDIWindow;
  37.   TMainMDIWindow = object(TMDIWindow)
  38.     ToolParent : PToolParent;
  39.     constructor Init(ATitle: PChar;  AMenu: HMenu);
  40.     procedure   CMTest(var Msg:tMessage); virtual cm_First+cm_Test;
  41.     function    CreateChild: PWindowsObject; virtual;
  42.   end;
  43.  
  44. constructor TToolChild.Init(AParent: PWindowsObject; ATitle: PChar);
  45. begin
  46.    ToolCollection := New(PCollection,Init(8,0));
  47.    with ToolCollection^ do
  48.    begin
  49.       Insert(New(PToolButton,Init('ToolBut_1_Up','ToolBut_1_Down')));
  50.       Insert(New(PToolButton,Init('ToolBut_2_Up','ToolBut_2_Down')));
  51.       Insert(New(PToolButton,Init('ToolBut_3_Up','ToolBut_3_Down')));
  52.       Insert(New(PToolButton,Init('ToolBut_4_Up','ToolBut_4_Down')));
  53.       Insert(New(PToolButton,Init('ToolBut_5_Up','ToolBut_5_Down')));
  54.       Insert(New(PToolButton,Init('ToolBut_6_Up','ToolBut_6_Down')));
  55.       Insert(New(PToolButton,Init('ToolBut_7_Up','ToolBut_7_Down')));
  56.       Insert(New(PToolButton,Init('ToolBut_8_Up','ToolBut_8_Down')));
  57.    end;
  58.    TToolBox.Init(AParent,ATitle,4,2,0,5,5);
  59. end;
  60.  
  61. procedure TToolChild.TBButtonHit(var Msg : TMessage);
  62. begin
  63.    MessageBeep(0);
  64. end;
  65.  
  66. constructor TToolParent.Init(AParent : PWindowsObject; ATitle : PChar);
  67. begin
  68.   TWindow.Init(AParent, ATitle);
  69.   with Attr do
  70.   begin
  71.     W := 200;
  72.     H := 200;
  73.   end;
  74. end;
  75.  
  76. procedure TToolParent.SetupWindow;
  77. begin
  78.   TWindow.SetupWindow;
  79.   ToolChild := PToolChild(Application^.MakeWindow(new(PToolChild, Init(@Self, 'Tools'))));
  80.   SendMessage(ToolChild^.HWindow,WM_NCActivate,1,0);
  81. end;
  82.  
  83. constructor TMainMDIWindow.Init(ATitle: PChar;  AMenu: HMenu);
  84. begin
  85.   TMDIWindow.Init(ATitle, AMenu);
  86. end;
  87.  
  88. function TMainMDIWindow.CreateChild: PWindowsObject;
  89. begin
  90.    ToolParent := PToolParent(Application^.MakeWindow(new(PToolParent, Init(@Self, 'ToolBox Parent'))));
  91. end;
  92.  
  93. procedure TMainMDIWindow.CMTest(var Msg:tMessage);
  94. begin
  95.    CreateChild;
  96. end;
  97.  
  98. procedure TToolDemoApp.InitMainWindow;
  99. begin
  100.   MainWindow := New(PMainMDIWindow, Init('ToolDemo',LoadMenu(HInstance, 'ToolMenu_1')));
  101. end;
  102.  
  103. { Declare a variable of type TToolDemo}
  104. var
  105.   ToolDemoApp: TToolDemoApp;
  106.  
  107. { Run the ToolDemoApp }
  108. begin
  109.   ToolDemoApp.Init('ToolDemoApp');
  110.   ToolDemoApp.Run;
  111.   ToolDemoApp.Done;
  112. end.
  113.